<template>
  <el-dialog
      v-model="ledgerDetailVisible"
      title="查看工装夹具台账详情"
      width="50%"
  >
    <template #default>
      <el-descriptions >
        <el-descriptions-item label="工装夹具编码">{{ledger.toolLedgerCode}}</el-descriptions-item>
        <el-descriptions-item label="工装夹具名称">{{ledger.toolLedgerName}}</el-descriptions-item>
        <el-descriptions-item label="工装夹具品牌">{{ledger.toolLedgerBrand}}</el-descriptions-item>
        <el-descriptions-item label="工装夹具型号">{{ledger.toolLedgerSpec}}</el-descriptions-item>
        <el-descriptions-item label="工装夹具类型">{{ledger.toolLedgerType}}</el-descriptions-item>
        <el-descriptions-item label="工装夹具库存数量">{{ledger.toolInventoryNum}}</el-descriptions-item>
        <el-descriptions-item label="工装夹具可用数量">{{ledger.toolAvailableNum}}</el-descriptions-item>
        <el-descriptions-item label="保养维护类型">{{ledger.maintainType}}</el-descriptions-item>
        <el-descriptions-item label="下次保养周期">{{ledger.serviceInterval}}</el-descriptions-item>
        <el-descriptions-item label="下次保养日期">{{ledger.maintainDate}}</el-descriptions-item>
        <el-descriptions-item label="状态">
          <el-tag type="info" v-if="ledger.toolLedgerStatus == 1">在库</el-tag>
          <el-tag type="success" v-else-if="ledger.toolLedgerStatus == 2">被领用</el-tag>
          <el-tag type="success" v-else-if="ledger.toolLedgerStatus == 3">报废</el-tag>
          <el-tag type="success" v-else-if="ledger.toolLedgerStatus == 4">维修中</el-tag>
        </el-descriptions-item>
      </el-descriptions>
    </template>
    <template #footer>
      <el-button @click="ledgerDetailVisible = false">关闭</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, watch} from "vue";
import ledgerRequest from "@/api/ledger.js";
import maintainPlanRequest from "@/api/maintainPlan.js";
import toolsTypeRequest from "@/api/toolsType.js";
import toolsLedgerRequest from "@/api/toolsLedger.js";
// 申明组件的属性
const props = defineProps(['toolLedgerId']);
// 弹窗标记
let ledgerDetailVisible = ref(false);
// 详情对象
let ledger = ref({})
// 通过id加载
function loadLedger(){
  toolsLedgerRequest.selectById(props.toolLedgerId,res=>{
    if(res.data){
      ledger.value = res.data;
      ledgerDetailVisible.value = true;
    }
  });
}
// 属性侦听
watch(()=>props.toolLedgerId,()=>{
  if(props.toolLedgerId){
    loadLedger();
  }
});

</script>
<style scoped>

</style>